function get(object, ...path) {
    return path.map((item) => {
        item.replace(/\[/g, ".")
            .replace(/\]/g, "")
            .split('.')
            .map(path => object = object && object[path]);
        return object;
    })
}

var obj = { "name": 1, "test": [9, 1] }

var ret = get(obj, "name", "test[0]")
console.log(ret);